<html>
<head><meta charset="utf-8"><title>Manageable HIR dumps · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html">Manageable HIR dumps</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="247243975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247243975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eholk <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247243975">(Jul 26 2021 at 18:39)</a>:</h4>
<p>Does anyone have any tips or tricks for looking at HIR dumps? I have a 20 line test program and the HIR was over 2000 lines long, and the interesting parts are all really deeply indented. I was wondering if anyone knew of better ways to look at this.</p>



<a name="247310396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247310396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247310396">(Jul 27 2021 at 09:14)</a>:</h4>
<p><span class="user-mention" data-user-id="421986">@eholk</span> does <code>rustfmt</code> work on it? I forget if it follows Rust syntax</p>



<a name="247311004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247311004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247311004">(Jul 27 2021 at 09:22)</a>:</h4>
<p>Mostly, but for example async fn results in mangled syntax last time I tried it.</p>



<a name="247311029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247311029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247311029">(Jul 27 2021 at 09:23)</a>:</h4>
<p>shouldn't it "just" be generators? I guess the <code>impl Trait</code> parts might be printed weird</p>



<a name="247311237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247311237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247311237">(Jul 27 2021 at 09:25)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">async</span><span class="w"> </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>
<p>gives</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[prelude_import]</span><span class="w"></span>
<span class="k">use</span><span class="w"> </span><span class="n">std</span>::<span class="n">prelude</span>::<span class="n">v1</span>::<span class="o">*</span><span class="p">;</span><span class="w"></span>
<span class="cp">#[macro_use]</span><span class="w"></span>
<span class="k">extern</span><span class="w"> </span><span class="k">crate</span><span class="w"> </span><span class="n">std</span><span class="p">;</span><span class="w"></span>
<span class="k">async</span><span class="w"> </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"></span>
<span class="w"> </span>-&gt;
     <span class="cm">/*impl Trait*/</span><span class="w"> </span><span class="cp">#[lang = </span><span class="s">"from_generator"</span><span class="cp">]</span><span class="p">(</span><span class="k">move</span><span class="w"> </span><span class="o">|</span><span class="k">mut</span><span class="w"> </span><span class="n">_task_context</span><span class="o">|</span><span class="w"></span>
<span class="w">                                                   </span><span class="p">{</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="n">_t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">};</span><span class="w"> </span><span class="n">_t</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">})</span><span class="w"></span>
</code></pre></div>



<a name="247311286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247311286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247311286">(Jul 27 2021 at 09:26)</a>:</h4>
<p>oh god</p>



<a name="247311321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247311321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247311321">(Jul 27 2021 at 09:26)</a>:</h4>
<p>okay the <code>#[lang = "..."]</code> is a bug. printing the HIR should be done at a point where those can be looked up (and the proper path printed)</p>



<a name="247311335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247311335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247311335">(Jul 27 2021 at 09:27)</a>:</h4>
<p>but also there's a lot more issues I guess</p>



<a name="247311456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247311456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247311456">(Jul 27 2021 at 09:28)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/60661">https://github.com/rust-lang/rust/issues/60661</a> (closed as not a bug)</p>



<a name="247311476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247311476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247311476">(Jul 27 2021 at 09:28)</a>:</h4>
<p>Tje output was better at that time.</p>



<a name="247311484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247311484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247311484">(Jul 27 2021 at 09:28)</a>:</h4>
<p>okay but, like,</p>



<a name="247311498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247311498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247311498">(Jul 27 2021 at 09:29)</a>:</h4>
<p>it's not a bug that it doesn't compile, but it is a bug that it's completely useless</p>



<a name="247311506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247311506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247311506">(Jul 27 2021 at 09:29)</a>:</h4>
<p>I agree</p>



<a name="247311507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247311507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247311507">(Jul 27 2021 at 09:29)</a>:</h4>
<p>and doesn't even have any logic to it</p>



<a name="247311961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247311961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247311961">(Jul 27 2021 at 09:34)</a>:</h4>
<p>I also just had an idea, of using macro syntax to hide "not expressible in normal Rust" stuff from e.g. <code>rustfmt</code></p>



<a name="247311979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247311979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247311979">(Jul 27 2021 at 09:35)</a>:</h4>
<p>(and reopened the issue at the same time - <a href="https://github.com/rust-lang/rust/issues/60661#issuecomment-887363016">https://github.com/rust-lang/rust/issues/60661#issuecomment-887363016</a>)</p>



<a name="247377576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247377576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eholk <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247377576">(Jul 27 2021 at 19:12)</a>:</h4>
<p>Ah, so I was using <code>-Z unpretty=hir-tree</code> since that's what the rustc dev guide suggested, but <code>-Z unpretty=hir</code> gives something a lot more readable.</p>



<a name="247377655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247377655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eholk <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247377655">(Jul 27 2021 at 19:12)</a>:</h4>
<p>It might be worth mentioning both in the dev guide. <code>hir-tree</code> obviously gives a lot more precise information, but it feels like <code>hir</code> will be more useful most of the time, at least at first.</p>



<a name="247380510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247380510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247380510">(Jul 27 2021 at 19:36)</a>:</h4>
<p>it is mentioned in the guide <a href="https://rustc-dev-guide.rust-lang.org/test-implementation.html?highlight=unpretty#inspecting-the-generated-code">https://rustc-dev-guide.rust-lang.org/test-implementation.html?highlight=unpretty#inspecting-the-generated-code</a> but in a somewhat unexpected chapter indeed</p>



<a name="247417297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Manageable%20HIR%20dumps/near/247417297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Manageable.20HIR.20dumps.html#247417297">(Jul 28 2021 at 03:11)</a>:</h4>
<p>Heh, I had the opposite problem the other day: I was using <code>-Zunpretty=hir</code> and wasn't getting enough info but I didn't know about <code>-Zunpretty=hir-tree</code>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>